#include <algorithm>
#include <cstdint>
#include <iostream>
#include <queue>
#include <string>
#include <vector>
using ll = int64_t;

void ptv(std::vector<ll>&v){
    std::cout<<"[";
    for(ll i=1;i<v.size();i++){
        std::cout<<v[i]<<" ,";
    }
    std::cout<<"]\n";
}

void solve(){
    static std::string s;
    std::cin>>s;
    s=' '+s;
    ll lok=-1;
    static std::vector<ll> lv;
    lv.clear();
    lv.resize(s.size(),0);
    static std::deque<ll> q;
    q.clear();
    for(ll i=1;i<s.size();i++){
        if(s[i]=='('){
            q.push_back(i);
        }else if(s[i]==')'){
            if(q.size()!=0){
                lv[i]=q.back();
                if(lok!=-1){
                    if(q.size()==1){
                        lv[i]=lok;
                    }
                }else{
                    lok=q.back();
                }
                q.pop_back();
            }else{
                lok=-1;
            }
        }
    }
    ptv(lv);
}

int main(){
    ll t;
    std::cin>>t;
    while(t--){
        solve();
    }
}